home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / hf^k-6.dms / in.adf / Install.run / GOLDEDDATA / developer / examples / scanner / source / autodoc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-30  |  1.7 KB  |  76 lines

  1. /* -----------------------------------------------------------------------------
  2.  
  3.   COPYIGHT
  4.  
  5.   ©1995  Dietmar  Eilert  (e-mail:  DIETMAR@TOMATE.TNG.OCHE.DE).  All  Rights
  6.   Reserved.  Code  may not be reused/reproduced without written permission of
  7.   the author.
  8.  
  9.   Dietmar Eilert
  10.   Mies-v-d-Rohe-Str.31, 52074 Aachen, Germany
  11.   E-Mail: DIETMAR@TOMATE.TNG.OCHE.DE
  12.   Tel: +49-(0)241-81665
  13.        +49-(0)2525-7776
  14.   Fax: +49-(0)241-81665
  15.  
  16.   Example: scan handler looking for  AutoDoc  nodes.  Scan  handlers  are  plain
  17.   functions  (LoadSeg'ed  by GED): no standard C startup code, no library calls.
  18.   This handler is faster than GoldED's built in AutoDoc handler since it  simply
  19.   looks  for formfeeds. Won't work with all AutoDocs though Commodore's AutoDocs
  20.   are handled properly.
  21.   
  22.   DICE C:
  23.  
  24.   dcc autodoc.c -// -l0 -md -mRR -o ram:autodoc
  25.  
  26.   ------------------------------------------------------------------------------
  27. */
  28.  
  29. #include <exec/types.h>
  30.  
  31. #define FORMFEED 12
  32.  
  33. ULONG
  34. ScanHandlerGuide(__D0 ULONG len, __A0 char **text, __A1 ULONG *line)
  35. {
  36.     // look for node header
  37.  
  38.     const char *version = "$VER: ADoc 1.3 (" __COMMODORE_DATE__ ")";
  39.  
  40.     if (**text == FORMFEED) {
  41.  
  42.         // look for beginning of header string (e.g. "Dos.Library/Open")
  43.  
  44.         while (len && (**text <= ' ')) {
  45.  
  46.             ++*text;
  47.             --len;
  48.         }
  49.  
  50.         // ignore first part of header string
  51.  
  52.         while (len && (**text != '/')) {
  53.  
  54.             ++*text;
  55.             len--;
  56.         }
  57.  
  58.         // extract node name
  59.  
  60.         if (len) {
  61.  
  62.             UWORD letters;
  63.  
  64.             ++*text;
  65.             --len;
  66.  
  67.             for (letters = 0; len && ((*text)[letters] != 32); --len)
  68.                 ++letters;
  69.  
  70.             return(letters);
  71.         }
  72.     }
  73.  
  74.     return(FALSE);
  75. }
  76.